<?php
/**
 *  
 */
class ClassName
{
	 private  $data;
    function __construct($data = []){
        $this->data = $data;
    }
    
	

	 /**
     * POST 请求（支持文件上传）
     * @param string $url HTTP请求URL地址
     * @param array|string $data POST提交的数据
     * @param int $second 请求超时时间
     * @param array $header 请求Header信息
     * @return bool|string
     */
     function post($url, $data = [], $second = 30, $header = [])
    {
        $curl = curl_init();
        self::applyData($data);
        self::applyHttp($curl, $url);
        curl_setopt($curl, CURLOPT_TIMEOUT, $second);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);   

        if (!empty($header)) {
        	//var_dump($header);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        }
        list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
        var_dump(json_decode($content,true));
        return (intval($status["http_code"]) === 200) ? $content : false;
    }

       /**
     * 设置SSL参数
     * @param $curl
     * @param string $url
     */
    private static function applyHttp(&$curl, $url)
    {
        if (stripos($url, "https") === 0) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSLVERSION, 1);
        }
    }

    private static function applyData(&$data, $isBuild = true)
    {
        if (!is_array($data)) {
            return null;
        }
        foreach ($data as &$value) {
            is_array($value) && $isBuild = true;
            if (!(is_string($value) && strlen($value) > 0 && $value[0] === '@')) {
                continue;
            }
            if (!file_exists(($file = realpath(trim($value, '@'))))) {
                continue;
            }
            list($isBuild, $mime) = [false, FileService::getFileMine(pathinfo($file, 4))];
            if (class_exists('CURLFile', false)) {
                $value = new CURLFile($file, $mime);
            } else {
                $value = "{$value};type={$mime}";
            }
        }
        $isBuild && $data = http_build_query($data);
    }

    /**
	*
	*/
    function ceshi($array) {
    	$url = 'https://paidui.51mx.com/api/subscribe/order';
    	$header= [
    		'content-type: application/x-www-form-urlencoded',
    		'Authorization: Bearer w8ka7LAz2YdN832Qi4fbXFAWVQtYIJiAAc6Yw3SlP2tsqODbpVEA9j5fu8oN'
    		//Bearer w8ka7LAz2YdN832Qi4fbXFAWVQtYIJiAAc6Yw3SlP2tsqODbpVEA9j5fu8oN
    		//Bearer OI70GmoTgfjAUQlqBMdWanBXrg5J0H2FagZ3HSTdm3d23AeY7S3ro6alpZFH
    	];
    	//var_dump($array);
    	$this->post($url,$array,20,$header);
    }

}
$data =['queue_day_id' => -1,
    	'queue_id' => '0ze6j0',
    	'contact_phone' => '13419771455',
    	'contact_name' => '京66669',
    	'expect' => -1,
    	'expect2' => -1,
    	'geo' => '[{}]',
    	'fields' =>  '[{"mode":"text","type":"input","index":0,"label":"车号+提货单位简称","value":"京66669","unique":true,"required":true,"selected":true,"placeholder":"请输入姓名"},{"mode":"auto","type":"phone","label":"手机号码","value":"13419771455","required":true,"selected":true,"placeholder":"请输入手机号","index":1},{"mode":"text","type":"input","index":2,"label":"真实姓名","value":"是是是","required":true,"selected":true,"type_name":"单行文本","placeholder":""}]'

    ];

    (new  ClassName())->ceshi( $data );





 ?>